#include "mainwindow.h"
#include "ui_mainwindow.h"

#include <QTextToSpeech>

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    QTextToSpeech *tts = new QTextToSpeech(this);
    tts->setLocale(QLocale::Chinese);//设置语言环境

    tts->setRate(0.0);//设置语速-1.0到1.0
    tts->setPitch(1.0);//设置音高-1.0到1.0
    tts->setVolume(1.0);//设置音量0.0-1.0


    if(tts->state()==QTextToSpeech::Ready)
    {
        tts->say("前方40米告警");//开始合成文本
    }


}

MainWindow::~MainWindow()
{
    delete ui;
}
